<{extend name="public/base"}>
<{block name="head_source"}>
<style type="text/css">
    .navigation-intend td:nth-child(1){
        padding-left:20px;
    }
</style>
<{/block}>
<{block name="content"}>

<div class="box">
    <div class="box-header">
        <h3 class="box-title"><{$title}></h3>
    </div>
    <!-- /.box-header -->
    <div class="box-body">


        <div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
                <li <{if condition="$permission eq 'admin/data/index'"}>class="active"<{/if}> ><a href="<?php echo url('admin/data/index'); ?>" >风格</a></li>
                <li <{if condition="$permission eq 'admin/data/brand'"}>class="active"<{/if}> ><a href="<?php echo url('admin/data/brand'); ?>" >品牌</a></li>
                <li <{if condition="$permission eq 'admin/data/product'"}>class="active"<{/if}> ><a href="<?php echo url('admin/data/product'); ?>" >产品</a></li>
            </ul>
            <div class="tab-content">

            </div>
        </div>

        <div class="form-group">
            <a id="syn_brand" href="javascript:;" class="btn btn-primary">同步品牌</a>
        </div>

        <table id="example1" class="table table-bordered table-striped">
            <thead>
            <tr>
                <{foreach name="column" id="item" key="k"}>
                <th><{$item.name}></th>
                <{/foreach}>
                <!--<th>操作</th>-->
            </tr>
            </thead>
            <tbody>
            <{volist name="model" id="item"}>
            <tr>
                <{foreach name="column" id="ii" key="kk"}>
                <td><?php echo  $parser->{$column[$kk]['fun']}($item[$kk],$column[$kk]['options']); ?></td>
                <{/foreach}>
                <!-- <td>
                     <a href="<{:url('admin/article/edit',array('id'=>$item['id']))}>" class="btn btn-primary btn-sm">编辑</a>
                     <a href="<{:url('admin/article/delete',array('id'=>$item['id']))}>" class="btn btn-danger btn-sm">删除</a>
                 </td>-->
            </tr>
            <{/volist}>

            </tbody>
            <tfoot>
            <tr>
                <{foreach name="column" id="item" key="k"}>
                <th><{$item.name}></th>
                <{/foreach}>
                <!--<th>操作</th>-->
            </tr>
            </tfoot>
        </table>
        <div><{$model->render()}></div>

        <div class="form-group" id="msg_panel" style="display:none;">
            <div id="show_status">正在同步中...</div>
            <div id="show_processing" class="" style="border:1px solid silver;padding:10px;color:red;" >

            </div>
        </div>

    </div>
    <!-- /.box-body -->

</div>

<{/block}>

<{block name="foot_script"}>
    <script type="text/javascript">
        $("#syn_brand").click(function(){
            var url = "<?php echo url('admin/data_api/resetUpdateState',['t'=>'styles','c'=>'is_brand_update']); ?>";
            $.get(url,function(data,status){
                if(data.code == 1){
                    $("#msg_panel").show();
                    function updateBrand(){
                        var api_url = '<?php echo url("admin/data_api/updateBrand"); ?>';
                        $.get(api_url,function(data,status){
                            if(data.code == 1){
                                //调用一下
                                $("#show_processing").prepend("<div>"+data.msg+"</div>");
                                updateBrand();
                            }else{
                                $("#show_status").html("<div>"+data.msg+"</div>");
                            }
                        });
                    }
                    updateBrand();
                }else{
                    alert(data.msg);
                }
            });
        });
    </script>
<{/block}>
